import request from '@/utils/request'
import { getToken } from '@/utils/auth'

export function login(res) {
  return request({
    url: '/api/admin/Login',
    method: 'post',
    params: res,
    headers: {
      Token: getToken()
    }
  })
}

export function getInfo(token) {
  return request({
    url: '/api/admin/getUserInfo',
    method: 'post',
    params: { token },
    headers: {
      Token: getToken()
    }
  })
}
export function GetPermissionInfo(id) {
  return request({
    url: '/api/admin/GetPermissionInfo',
    method: 'post',
    params: id,
    headers: {
      Token: getToken()
    }
  })
}
export function logout() {
  return request({
    url: '/api/admin/LoginOut',
    method: 'post'
  })
}

export function getUserList(name, role, page, limit) {
  return request({
    url: '/api/admin/getUserList',
    method: 'get',
    headers: {
      Token: getToken()
    },
    params: { 'name': name, 'role': role, 'page': page, 'limit': limit }
  })
}
export function CheckUserStatus(status, id) {
  return request({
    url: '/api/admin/CheckUserStatus',
    method: 'get',
    headers: {
      Token: getToken()
    },
    params: { 'status': status, 'id': id }
  })
}
export function deleteUser(id) {
  return request({
    url: '/api/admin/deleteUser',
    method: 'get',
    params: { 'id': id },
    headers: {
      Token: getToken()
    }
  })
}
export function updateUser(res) {
  return request({
    url: '/api/admin/updateUser',
    method: 'post',
    params: res,
    headers: {
      Token: getToken()
    }
  })
}
export function addUser(res) {
  return request({
    url: '/api/admin/addUser',
    method: 'post',
    headers: {
      Token: getToken()
    },
    params: res
  })
}
export function GetRoleList() {
  return request({
    url: '/api/admin/GetRoleAll',
    method: 'get',
    headers: {
      Token: getToken()
    }
  })
}

